<template>
  <div class="login">
    <input placeholder="用户名" v-model="username"/>
    <input type="password" placeholder="密码" v-model="password"/>
    <button @click="onClick()">提交</button>
    <div @click="jumpTo()">跳转</div>
  </div>
</template>

<script>
  import axios from 'axios'
  import qs from 'qs'
  export default {
    name: 'login',
    data() {
      return {
        username: '',
        password: ''
      }
    },
    methods: {
      onClick() {
        if (this.username === '') {
          window.alert('用户名不能为空')
          return
        }
        if (this.password === '') {
          window.alert('密码不能为空')
          return
        }
//      axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
        let token = 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJiMGQ4OTMxNS1iOTkwLTRjM2EtODA4Yy05Nzk0MGNlMWE1ZjkiLCJleHAiOjE1MDI2NzAyNzV9.scetoiQn_Kj9vQ6GCBHQmS1ey7P92Uzs5rqImUZs2QwLWekRl6i4n6hyURQge9lHP12f29AuArSfD6-SpfJkNQ'
        axios.get('http://localhost:8888/user/token/' + '' + token + '')
          .then((response) => {
            console.log(response);
            this.result = response.data;
          })
          .catch((error) => {
            console.log(error);
          });

//        axios.post('http://localhost:9090/login', qs.stringify({
//          username: this.username,
//          password: this.password
//        }))
//          .then((response) => {
//            console.log(response);
//            this.result = response.data;
//          })
//          .catch((error) => {
//            console.log(error);
//          });
      },
      jumpTo() {
        window.location.href = 'http://tietie.natapp1.cc/?#/pay'
      }
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
